#include<bits/stdc++.h>
#define int long long
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
const int N=5e5+5,Mod=1e9+7;
//char buf[(1<<21)+5],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void chmx(int &x,int y){(x<y)&&(x=y);}
void chmn(int &x,int y){(x>y)&&(x=y);}
typedef __int128_t i128;
i128 _base=1;
inline int mol(int x){return x-Mod*(_base*x>>64);}
inline void Add(int &x,int y){x=mol(x+y+Mod);}
inline int read(){
	int f=0,x=0;
	char ch=getchar();
	while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?-x:x;
}
char mp[305][305];
int n,m;
int a[305][305];
int C[305][305];
int gg[N],tot;
int dp[17][N];
inline int getid(int x,int y){return (x-1)*m+y-1;}
inline int ksm(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=res*a%Mod;
		a=a*a%Mod;
		b>>=1;
	}
	return res;
	}
signed main(){
	_base=(_base<<64)/Mod;
	freopen("disanti.in","r",stdin);
	freopen("disanti.out","w",stdout);
n=read(),m=read();
	For(i,1,n){
		scanf("%s",mp[i]+1);
		For(j,1,m)a[i][j]=mp[i][j]-'0';
	}
	C[1][1]=C[1][0]=1;
	For(i,2,300){
		C[i][0]=1;
		For(j,1,300){
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%Mod;
		}
	}
	a[1][0]=-1;
	if(n==1){
		For(i,1,m){
			a[1][i]^=1;
			int k=1,ans=1;
			tot=0;
			For(j,2,m){
				if(a[1][j]!=a[1][j-1]){
					gg[++tot]=k;k=0;
				}
				k++;
			}
			gg[++tot]=k;
			For(j,1,tot){
				//~ cout<<gg[j]<<" ";
				int res=1;
				For(t,1,gg[j]-1){
					res=res*2;
					res%=Mod;
				}
				ans=ans*res%Mod;
			}
			printf("%lld ",ans);
			a[1][i]^=1;
		}
		return 0;
	}
	For(ii,1,n){For(jj,1,m){
		a[ii][jj]^=1;
		For(j,0,16)For(i,0,(1<<(n*m))-1) dp[j][i]=0;
		dp[0][0]=1;
		int ans=0;
		int p=1;
		For(j,0,n*m){
			if(j)p*=j;
			p%=Mod;
			For(i,0,(1<<(n*m))-2){
				//~ cout<<j<<' '<<i<<" "<<dp[j][i]<<endl;
				if(!dp[j][i]) continue;
				For(x,1,n)For(y,1,m){
					if(i&(1<<getid(x,y)))continue;
					int p=i;
					For(t,1,16){
						if(x+t-1>n) break;
						if(i&(1<<getid(x+t-1,y)))break;
						if(t!=1&&a[x+t-1][y]!=a[x+t-2][y]) break;
						p|=(1<<getid(x+t-1,y));
						dp[j+1][p]+=dp[j][i];
						dp[j+1][p]%=Mod;
					}
					p=i;
					For(t,1,16){
						if(y+t-1>m) break;
						if(i&(1<<getid(x,y+t-1)))break;
						if(t!=1&&a[x][y+t-1]!=a[x][y+t-2]) break;
						p|=(1<<getid(x,y+t-1));
						if(t==1) continue;
						dp[j+1][p]+=dp[j][i];
						dp[j+1][p]%=Mod;
					}
				}
			}
			//~ cout<<p<<" "<<dp[j][(1<<(n*m))-1]<<endl;
			ans+=ksm(p,Mod-2)*dp[j][(1<<(n*m))-1]%Mod;
		}
		a[ii][jj]^=1;
		printf("%lld ",ans%Mod);
	}puts("");}
#ifdef LOCAL
    Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}
